﻿Public Class RmodeloInmueble

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idProyecto As Int32, ByVal idEtapa As Int32) As List(Of EmodeloInmueble)
        Dim modelos As List(Of EmodeloInmueble) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                modelos = DmodeloInmueble.SeleccionarTodo(descEmpresa, idProyecto, idEtapa)
                If modelos Is Nothing Then modelos = New List(Of EmodeloInmueble)
                If DisplaySelect Then modelos.Insert(0, New EmodeloInmueble("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return modelos
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pModeloInmueble As EmodeloInmueble) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DmodeloInmueble.Añadir(descEmpresa, pModeloInmueble)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pModeloInmueble As EmodeloInmueble) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DmodeloInmueble.Editar(descEmpresa, pModeloInmueble)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pModeloInmueble As EmodeloInmueble) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DmodeloInmueble.Eliminar(descEmpresa, pModeloInmueble)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    '******* RptGerenciales xModelos *******'
    Public Shared Function rptGerenciales_xModelo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal rptGerencial As EproformaCabecera) As List(Of EmodeloInmueble)
        Dim modelos As List(Of EmodeloInmueble) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                modelos = DmodeloInmueble.rptGerenciales_xModelo(descEmpresa, rptGerencial)
                If modelos Is Nothing Then modelos = New List(Of EmodeloInmueble)
                'If DisplaySelect Then accions.Insert(0, New xOperaciones("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return modelos
    End Function

End Class
